package com.fcl.oschina.util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.fcl.oschina.AppContext;
import com.fcl.oschina.R;


/**
 * Created by fang on 2016/9/5.
 */
public class ToastUtil {

    /**
     * 自定义toast样式
     * @param context
     * @param content
     */
    public static void showDefineToast(String content) {
        Context context = AppContext.getInstance();
        View view = LayoutInflater.from(context).inflate(R.layout.toast_layout, null);
        ((TextView)view.findViewById(R.id.toast_content)).setText(content);
        Toast toast = new Toast(context);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(view);
        toast.show();
    }

    public static void showDefineToast(int content) {
        Context context = AppContext.getInstance();
        View view = LayoutInflater.from(context).inflate(R.layout.toast_layout, null);
        ((TextView)view.findViewById(R.id.toast_content)).setText(content);
        Toast toast = new Toast(context);
        toast.setDuration(Toast.LENGTH_SHORT);
        toast.setView(view);
        toast.show();
    }

}
